﻿using System;
using System.Collections.Generic;
using System.Text;
using AppToolKit.Data;
using AppToolKit.Core.Context.Spring;
using System.Data;
using Utility;

namespace BLL.Business.ActionBusiness
{
    public class ActionBusinessDao:IAutoWiring
    {
        [AutoWiring]
        public IDbProcessor DbProcessor { get; set; }

        internal void Update(string sql, string sqlPrimaryKey, string tableName)
        {
           string sqlEnd = string.Format("update {2} set {0} where {1}", sql, sqlPrimaryKey, tableName);
           //LogHelper.GetInfoLog().Debug(sqlEnd);
           DbProcessor.ExecuteNonQuery(CommandType.Text, sqlEnd);
        }

        internal void Insert(string tableName, string strSqlName, string strSqlValue)
        {
            string strSql = string.Format("insert into {0} ({1}) values({2})", tableName, strSqlName, strSqlValue);
            //LogHelper.GetInfoLog().Debug(strSql);
            DbProcessor.ExecuteNonQuery(CommandType.Text, strSql);
        }

        internal object Exist(string sql)
        {
            //LogHelper.GetInfoLog().Debug(sql);
          return   DbProcessor.ExecuteScalar(CommandType.Text, sql);
        }
    }
}
